/*
 * @Author: your name
 * @Date: 2024-03-21 22:28:04
 * @LastEditTime: 2024-03-21 22:45:06
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\26.删除有序数组中的重复项.cpp
 */
/*
 * @lc app=leetcode.cn id=26 lang=cpp
 *
 * [26] 删除有序数组中的重复项
 */

// @lc code=start
class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int slow = 0, tmp_val = 10001;
        for (int fast = 0; fast < nums.size(); fast++)
        {
            if(nums[fast]!= tmp_val){
                nums[slow++] = nums[fast];
                tmp_val = nums[fast];
            }
        }
        return slow;
        
    }
};
// @lc code=end
// 使用一个tmp去记录每一次新的需要过滤的值
